package com.rybbaby.tss.platform.ueditor.controller;

import com.baidu.ueditor.ActionEnter;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.qiniu.storage.model.DefaultPutRet;
import com.rybbaby.tss.core.annotation.RequestLog;
import com.rybbaby.tss.core.annotation.validator.RegexpValidator;
import com.rybbaby.tss.core.bean.TempUploadFile;
import com.rybbaby.tss.core.utils.*;
import com.rybbaby.tss.core.utils.pojo.Size;
import com.rybbaby.tss.core.web.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import javax.json.Json;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

/**
 * @author 雷春琼
 * @description 编辑器响应路径
 * @createDate 2017-12-26 下午17:30:17
 */
@Controller
@RequestMapping(value = "ueditor")
public class UeditorController extends BaseController {

    /**
     * 请求编辑器接口
     *
     * @return
     * @throws IOException
     */
    @RequestLog(content = "请求编辑器接口", save = true)
    @RequestMapping(value = "/cmd", method = RequestMethod.POST)
    public void sysFileUseLogList(HttpServletRequest request, HttpServletResponse response) {
        try {
            response.setContentType("application/json");
            request.setCharacterEncoding("utf-8");
            String rootPath = request.getSession().getServletContext().getRealPath("/");
            String exec = new ActionEnter(request, rootPath).exec();
            PrintWriter writer = response.getWriter();
            writer.write(exec);
            writer.flush();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
